package by.kniazhych.core.view.game.selector {
	
	/**
	 * ...
	 * @author Boutylin Mikhail
	 */
	
		import by.kniazhych.core.view.game.peace.PeaceViewFactory;
		import by.vaukalak.core.display.array.DisplayArray;
		import flash.display.Sprite;
	

	
	public class Selector extends Sprite{
		
		
		public function Selector() {
			super();
			
		}
		
		public function populate(arr:Array):void {
			_items.clear();
			for (var i:int = 0; i < arr.length; i++) {
				_items.push(new SelectorItem(_factory, arr[i]));
			}
			graphics.clear();
			graphics.lineStyle(2, 0);
			graphics.beginFill(0xffffff);
			graphics.drawRect(0, -10, _items.width + 40, _items.height + 20);
		}
		
		
		private var p_factory:PeaceViewFactory;
		private function get _factory():PeaceViewFactory {
			if (!p_factory) p_factory = new PeaceViewFactory();
			return p_factory;
		}
		
		private var p_items:DisplayArray;
		private function get _items():DisplayArray {
			if (!p_items) {
				p_items = new DisplayArray();
				p_items.x = 20;
				p_items.objectDistanse = 10;
				addChild(p_items);
			}
			return p_items;
		}
		
	}

}